import Button from "components/Base/Button";
import Icon from "components/Base/Icon";
import DataTable from "components/Base/DataTable";
import {getBpDeviceType} from "../../../../models/deviceType";
import moment from "moment";

export default (self) => [

  {
    title: 'id',
    name: 'id',
    formItem: {
      type: 'hidden',
    }
  },
  {
    title: '软件版本',
    name: 'version',
    tableItem: {
    },
    formItem: {
      rules: [
        {
          required: true,
          message: '请输入软件版本'
        }
      ]
    },
  },
  {
    title: '软件上传',
    name: 'softFile',
    formItem: {
      type: 'upload',
      action: 'https://httpbin.org/post', // 后台接口 例：/uploadFile 会走代理
      fileName: 'file1', // 后台接收的名字
      rules: [
        {
          required: true,
          message: '请上传软件'
        }
      ]
    }
  },
  {
    title: '上传时间',
    name: 'upTime',
    tableItem: {
    },
    formItem: {
      type: 'hidden'
    }
  },
  {
    title: '每个版本下的设备数量',
    name: 'deviceCount',
    tableItem: {
    },
    formItem: {
      type: 'hidden'
    }
  },

  {
    title: '最新版本',
    name: 'lastVersion',
    dict: [
      { code: 'Y', codeName: '新版' },
      { code: 'N', codeName: '老版' },
    ],
    tableItem: {
    },
    formItem: {
      type: 'select',
      rules: [
        {
          required: true,
          message: '请选择是否为新版本'
        }
      ]
    },
  },

  {
    title: '操作',
    tableItem: {
      width: 180,
      align: 'center',
      render: (text, record) => (
        <DataTable.Oper>
          <Button tooltip="修改" onClick={e => self.onUpdate(record)}>
            <Icon type="edit"/>
          </Button>
          <Button tooltip="删除" onClick={e => self.onDelete(record)}>
            <Icon type="trash"/>
          </Button>
          <Button tooltip="详情" onClick={e => self.onDelete(record)}>
            <Icon antd={true} type="snippets" />
          </Button>
        </DataTable.Oper>
      )
    }
  }
]
